**** Colombian replication copyright Lydia Tiede @2019
*/Do.Colombia.replicationFile.september1.2019.Final.do
*To use with :  Colombia.replication.data.FINAL.august 31, 2019


*/variable names
*pres1_appt = Presidential nominee
*SC1_appt  = Supreme Court nominee
*Consejo_appt = Consejo  nominee (base group) 
*liberal_appt  = Judge associated with liberal party
*conserv_appt = Judge associated with conservative party (base group)
*tenure = Judges tenure
*statutory_law = Case involves statutory law
*international_treaty = Case involves an international treaty
*all_rights_dummy = Case involves rights
*subnational_gov_dummy = Case involves subnational governments
*SOP_dummy = Case involves separation of powers
*totaljNEW = number of judges and integrantes or supplemental judges on case.
*totaljmNEW = number of judges and integrantes minus 1

*pres1apptavgN_other =  Average other judges nominated by the president
*SC1apptavgN_other   = Average other judges nominated by the supreme court
*liberalapptavgN_other = Average other judges associated with the liberal party
*year2001 = composition change 1 (2001)
*year2009 = composition change 2 (2009)

*nnewid1  = each unique decisional paragraph within case
*encode Sentencia, gen(rol_2)
*rol_2 = encoded number for each unique case (which is the variable Sentencia for clustering)


*/creation of variables
*use nnewid1 to make variables
*** Creation of panel effects variables
*gen totaljmNEW=totaljNEW-1
*totaljmNEW = number of judges appearing on case minus 1
*egen pres1apptN_sum = sum(pres1_appt), by(nnewid1)
*gen pres1apptavgN_other= (pres1apptN_sum-pres1_appt)/totaljmNEW

*egen SC1apptN_sum= sum(SC1_appt), by(nnewid1)
*gen SC1apptavgN_other= (SC1apptN_sum-SC1_appt)/totaljmNEW

*egen liberalapptN_sum = sum(liberal_appt), by(nnewid1)
*gen liberalapptavgN_other=(liberalapptN_sum-liberal_appt)/totaljmNEW




****MAIN TEXT RESULTS FOR TABLE 3.  
***EQUATION 1:  INSTITUTIONS ONLY
*** random intercept by case, which is rol_2, not individual decisional paragraph which nnewid1
xtset rol_2
xtprobit vote_unc2a   pres1_appt SC1_appt tenure statutory_law international_treaty all_rights_dummy subnational_gov_dummy SOP_dummy pres1apptavgN_other SC1apptavgN_other year2001 year2009 , i(rol_2) vce(robust) nolog
estat ic

***EQUATION 2:  PARTY ONLY
xtset rol_2
xtprobit vote_unc2a liberal_appt   tenure statutory_law international_treaty all_rights_dummy subnational_gov_dummy SOP_dummy liberalapptavgN_other year2001 year2009 , i(rol_2) vce(robust) nolog
estat ic

***EQUATION 3:  INSTITUTIONS AND PARTY
xtset rol_2
xtprobit vote_unc2a pres1_appt SC1_appt liberal_appt   tenure statutory_law international_treaty all_rights_dummy subnational_gov_dummy SOP_dummy pres1apptavgN_other SC1apptavgN_other liberalapptavgN_other year2001 year2009 , i(rol_2) vce(robust) nolog
estat ic

***PREDICTED PROBABILITES FOR MAIN REGRESSIOS
***EQUATION 1: INSTITUTIONS ONLY
xtset rol_2
xtprobit vote_unc2a   pres1_appt SC1_appt tenure statutory_law international_treaty all_rights_dummy subnational_gov_dummy SOP_dummy pres1apptavgN_other SC1apptavgN_other year2001 year2009 , i(rol_2) vce(robust) nolog
margins, dydx(pres1_appt) atmeans 
margins, dydx(SC1_appt) atmeans
margins, dydx(statutory_law) atmeans
margins, dydx(international_treaty) atmeans
margins, dydx(all_rights_dummy) atmeans
margins, dydx(subnational_gov_dummy) atmeans
margins, dydx(SOP_dummy)
margins, dydx(year2001)
margins, dydx(year2009)
margins, at(tenure=(0(1)9))atmeans
margins, at(pres1apptavgN_other=(0(.10).625)) atmeans
margins, at(SC1apptavgN_other=(0(.10) .5)) atmeans


***EQUATION 2:  PARTY ONLY
xtset rol_2
xtprobit vote_unc2a liberal_appt   tenure statutory_law international_treaty all_rights_dummy subnational_gov_dummy SOP_dummy liberalapptavgN_other year2001 year2009 , i(rol_2) vce(robust) nolog
margins, dydx(liberal_appt) atmeans
margins, dydx(statutory_law) atmeans
margins, dydx(international_treaty) atmeans
margins, dydx(all_rights_dummy) atmeans
margins, dydx(subnational_gov_dummy) atmeans
margins, dydx(SOP_dummy)
margins, dydx(year2001)
margins, dydx(year2009)
margins, at(tenure=(0(1)9))atmeans
margins, at(liberalapptavgN_other=(0(.10).875)) atmeans

***EQUATION 3:  INSTITUTIONS AND PARTY
xtset rol_2
xtprobit vote_unc2a pres1_appt SC1_appt liberal_appt   tenure statutory_law international_treaty all_rights_dummy subnational_gov_dummy SOP_dummy pres1apptavgN_other SC1apptavgN_other liberalapptavgN_other year2001 year2009 , i(rol_2) vce(robust) nolog
margins, dydx(pres1_appt) atmeans
margins, dydx(SC1_appt) atmeans
margins, dydx(liberal_appt) atmeans
margins, dydx(statutory_law) atmeans
margins, dydx(international_treaty) atmeans
margins, dydx(all_rights_dummy) atmeans
margins, dydx(subnational_gov_dummy) atmeans
margins, dydx(SOP_dummy)
margins, dydx(year2001)
margins, dydx(year2009)
margins, at(tenure=(0(1)9))atmeans
margins, at(pres1apptavgN_other=(0(.10).625)) atmeans
margins, at(SC1apptavgN_other=(0(.10) .5)) atmeans
margins, at(liberalapptavgN_other=(0(.10).875)) atmeans

***Robustness checks
***  Supplemental Materials.  Table 2.2.  Colombia CC with tenure as only judge level variable
xtset rol_2
xtprobit vote_unc2a  tenure statutory_law international_treaty all_rights_dummy subnational_gov_dummy SOP_dummy pres1apptavgN_other SC1apptavgN_other   year2001 year2009 , i(rol_2) vce(robust)
estat ic



**Variables to keep
*keep vote_unc2a Sentencia paragraph  paragraph_unique_id1 id_Sentencia judges nnewid1 pres1_appt SC1_appt Consejo_appt liberal_appt conserv_appt  tenure statutory_law international_treaty all_rights_dummy subnational_gov_dummy SOP_dummy pres1apptavgN_other SC1apptavgN_other liberalapptavgN_other year2001 year2009 judgeC totaljNEW  year mydate

